#pragma once

#include <cocos2d.h>
#include "Bullet.h"
#include "PlayerPlane.h"
#include "EnemyManager.h"
#include "Enemy.h"
#include "EffectManager.h"
#include "Map.h"
#include "StateBar.h"
#include "Speedrun_Bar.h"
#include "PlayerHealthBar.h"
#include "Pet.h"

USING_NS_CC;

class Item;
class InputLayer;

class MainLayer : public CCLayer
{
public:
	MainLayer(void);
	~MainLayer(void);
	void addEnemy(Enemy* enemy);
	void removeEnemy(Enemy* enemy);

	void addPlayerBullet(Bullet* bullet);
	void removePlayerBullet(Bullet* bullet);

	void removeEnemyBullet(Bullet* bullet);
	void addEnemyBullet(Bullet* bullet);

	void addItem(Item* item);
	void removeItem(Item* item);

	virtual bool init();
	virtual void onEnter();
	virtual void onExit();

	CREATE_FUNC(MainLayer);

	CC_SYNTHESIZE_RETAIN(PlayerPlane*, _myPlant, MyPlant);
	CC_SYNTHESIZE_RETAIN(Pet*, _pet1, Pet1);
	CC_SYNTHESIZE_RETAIN(Pet*, _pet2, Pet2);
	CC_SYNTHESIZE_RETAIN(CCArray*, _listPlayerBullet, PlayerBullets);
	CC_SYNTHESIZE_RETAIN(CCArray*, _listEnemyBullet, EnemyBullets);
	CC_SYNTHESIZE_RETAIN(CCArray*, _listEnemy, Enemies);
	CC_SYNTHESIZE_RETAIN(CCArray*, _listItem, Items);
	CC_SYNTHESIZE_RETAIN(EnemyManager*, _enemyManager, EnemyManager);
	CC_SYNTHESIZE_RETAIN(EffectManager*, _effectManager, EffectManager);
 	CC_SYNTHESIZE_RETAIN(Map*, _map, Map);
	CC_SYNTHESIZE(bool, _isPause, IsPause);

	/* SCORE DATA */
	CC_PROPERTY(int, _score, Score);
	CC_PROPERTY(int, _star, Star);
	CC_PROPERTY(float, _kilomet, Kilomet);

	
	/* Bullet will delete if it be outside */
	CC_SYNTHESIZE(CCRect, _bulletArea, BulletArea);

	void initGameElement();
	void initUI();
	void update(float dt);
	void startShoot(CCNode* sender);
	void callbackEndGame(CCNode* sender);
	void pauseGame();
	void resumeGame();
	void endGame();
	InputLayer* getInputLayer();
	virtual void keyBackClicked();

	Enemy* testa;
};

